home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / dos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  12.6 KB  |  401 lines

  1. /*  dos.h
  2.  
  3.     Defines structs, unions, macros, and functions for dealing
  4.     with MSDOS and the Intel iAPX86 microprocessor family.
  5.  
  6. */
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.0
  9.  *
  10.  *      Copyright (c) 1987, 1998 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   9.9  $ */
  15.  
  16. #ifndef __DOS_H
  17. #define __DOS_H
  18.  
  19. #ifndef ___STDDEF_H
  20. #include <_stddef.h>
  21. #endif
  22.  
  23. #ifndef __ERRNO_H
  24. #include <errno.h>
  25. #endif
  26.  
  27. #if !defined(RC_INVOKED)
  28.  
  29. #if defined(__STDC__)
  30. #pragma warn -nak
  31. #endif
  32.  
  33. #pragma pack(push, 1)
  34.  
  35. #endif  /* !RC_INVOKED */
  36.  
  37. /* Define intrinsic outside of any namespace */
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. void     _RTLENTRY             __int__(int __interruptnum);
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. namespace std {
  48. #endif /* __cplusplus */
  49.  
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55.  
  56. #define FA_NORMAL   0x00        /* Normal file, no attributes */
  57. #define FA_RDONLY   0x01        /* Read only attribute */
  58. #define FA_HIDDEN   0x02        /* Hidden file */
  59. #define FA_SYSTEM   0x04        /* System file */
  60. #define FA_LABEL    0x08        /* Volume label */
  61. #define FA_DIREC    0x10        /* Directory */
  62. #define FA_ARCH     0x20        /* Archive */
  63.  
  64. /* MSC names for file attributes */
  65. #define _A_NORMAL   0x00        /* Normal file, no attributes */
  66. #define _A_RDONLY   0x01        /* Read only attribute */
  67. #define _A_HIDDEN   0x02        /* Hidden file */
  68. #define _A_SYSTEM   0x04        /* System file */
  69. #define _A_VOLID    0x08        /* Volume label */
  70. #define _A_SUBDIR   0x10        /* Directory */
  71. #define _A_ARCH     0x20        /* Archive */
  72.  
  73. #define SEEK_CUR    1
  74. #define SEEK_END    2
  75. #define SEEK_SET    0
  76.  
  77.  
  78. #if !defined(__STDC__)
  79. #define environ  _environ
  80. #endif
  81.  
  82.  
  83. struct  dfree
  84. {
  85.     unsigned df_avail;
  86.     unsigned df_total;
  87.     unsigned df_bsec;
  88.     unsigned df_sclus;
  89. };
  90.  
  91. struct diskfree_t
  92. {
  93.     unsigned total_clusters;
  94.     unsigned avail_clusters;
  95.     unsigned sectors_per_cluster;
  96.     unsigned bytes_per_sector;
  97. };
  98.  
  99. struct time
  100. {
  101.     unsigned char   ti_min;     /* Minutes */
  102.     unsigned char   ti_hour;    /* Hours */
  103.     unsigned char   ti_hund;    /* Hundredths of seconds */
  104.     unsigned char   ti_sec;     /* Seconds */
  105. };
  106.  
  107. struct dostime_t
  108. {
  109.     unsigned char hour;         /* Hours */
  110.     unsigned char minute;       /* Minutes */
  111.     unsigned char second;       /* Seconds */
  112.     unsigned char hsecond;      /* Hundredths of seconds */
  113. };
  114.  
  115. struct date
  116. {
  117.     int     da_year;        /* Year - 1980 */
  118.     char    da_day;     /* Day of the month */
  119.     char    da_mon;     /* Month (1 = Jan) */
  120. };
  121.  
  122. struct dosdate_t
  123. {
  124.     unsigned char day;      /* 1-31 */
  125.     unsigned char month;    /* 1-12 */
  126.     unsigned int  year;     /* 1980 - 2099 */
  127.     unsigned char dayofweek;/* 0 - 6 (0=Sunday) */
  128. };
  129.  
  130. #ifndef _FFBLK_DEF
  131. #define _FFBLK_DEF
  132. struct  ffblk   {
  133.     long            ff_reserved;
  134.     long            ff_fsize;
  135.     unsigned long   ff_attrib;
  136.     unsigned short  ff_ftime;
  137.     unsigned short  ff_fdate;
  138.     char            ff_name[256];
  139. };
  140. struct  _wffblk {
  141.     long            ff_reserved;
  142.     long            ff_fsize;
  143.     unsigned long   ff_attrib;
  144.     unsigned short  ff_ftime;
  145.     unsigned short  ff_fdate;
  146.     wchar_t         ff_name[256];
  147. };
  148.  
  149. #endif  /* __FFBLK_DEF */
  150.  
  151. struct find_t
  152. {
  153.     long            reserved;
  154.     long            size;              /* size of file */
  155.     unsigned long   attrib;            /* attribute byte for matched file */
  156.     unsigned short  wr_time;           /* time of last write to file */
  157.     unsigned short  wr_date;           /* date of last write to file */
  158.     char            name[256];         /* asciiz name of matched file */
  159. };
  160.  
  161. /*
  162.    The prototype for __emit__ has been removed from DOS.H.  __emit__ is
  163.    still supported, but is now automatically recognized by the compiler and
  164.    can preform some new features, now that it's un-prototyped:
  165.  
  166.    __emit__ usually works with constant numbers of size char, short, long,
  167.    and __int64, however, there are three special additions here:
  168.  
  169.      int x;
  170.      __emit__(&x);
  171.  
  172.    This will emit the address of the variable x in the correct little-endian
  173.    form to be used in assembly operations.
  174.  
  175.      __emit__(1.234F);
  176.      __emit__(1.234);
  177.      __emit__(1.234L);
  178.  
  179.    These emit the 4, 8, or 10 byte pattern that represents the constant
  180.    float, double, or long double values.
  181.  
  182.      __emit__("Hello There");
  183.  
  184.    This will create a constant string (just as any the compiler does with
  185.    and constant string in C or C++) and the 4-byte address of this string is
  186.    emitted.
  187.  
  188.    There is a special byte-saving optimization made if a signed
  189.    int constant number is specified: the fewest number of bytes required
  190.    to represent that number will be emmitted.  If the same value is cast
  191.    or suffixed to be unsigned int instead, the full size is emitted.  Keep
  192.    in mind that all integral literals are by definition, signed integers:
  193.  
  194.      __emit__(0);            // yields an 8-bit 00h not a 32-bit 00000000h
  195.                                 use __emit__(0u) to get 32-bits.
  196.  
  197.      __emit__(0x64);         // yields an 8-bit 64h
  198.      __emit__(100u);         // yields a 32-bit 00000064h
  199.      __emit__(0x64u);        // yields a 32-bit 00000064h
  200.  
  201.      __emit__((char) 50);    // yields an 8-bit 32h
  202.      __emit__((short) 500);  // yields a 16-bit 01F4h
  203.  
  204.      __emit__(2ui64);        // yields a 64-bit 0000000000000002h
  205.      __emit__(20i64);        // yields a 64-bit 0000000000000014h
  206.  
  207.    Multiple parameters can be passed to __emit__ and they will be generated
  208.    from left to right (similar to the pascal calling convention).  The left
  209.    most parameter will be emmitted to a lower address in memory than the
  210.    right most parameter.
  211.  
  212.     __emit__(0,1,2,3,4);              // yields 5 bytes: 0001020304
  213.     __emit__(L'\x8C\x1F', 0, 300i64); // yields 11 bytes:8C1F001201000000000000
  214.  
  215. */
  216.  
  217. unsigned _RTLENTRY  _EXPFUNC32 _dos_close(int __fd);
  218. unsigned _RTLENTRY  _EXPFUNC32 _dos_creat(const char _FAR *__pathP, unsigned __attr,
  219.                                           int _FAR *__fd);
  220. unsigned _RTLENTRY  _EXPFUNC32 _dos_creatnew(const char _FAR *__pathP, unsigned __attr,
  221.                                              int _FAR *__fd);
  222. unsigned _RTLENTRY  _EXPFUNC32 _dos_findfirst(const char _FAR *__path,
  223.                                               unsigned __attrib,
  224.                                               struct find_t _FAR *__finfo);
  225. unsigned _RTLENTRY  _EXPFUNC32 _dos_findnext(struct find_t _FAR *__finfo);
  226. void     _RTLENTRY  _EXPFUNC32 _dos_getdate(struct dosdate_t _FAR *__datep);
  227. unsigned _RTLENTRY  _EXPFUNC32 _dos_getdiskfree(unsigned __drive,
  228.                                                 struct diskfree_t _FAR *__dtable);
  229. void     _RTLENTRY  _EXPFUNC32 _dos_getdrive(unsigned _FAR *__drive);
  230. unsigned _RTLENTRY  _EXPFUNC32 _dos_getfileattr(const char _FAR *__filename,
  231.                                                 unsigned _FAR *__attrib);
  232. unsigned _RTLENTRY  _EXPFUNC32 _dos_getftime(int __fd, unsigned _FAR *__date,
  233.                                              unsigned _FAR *__time);
  234. void     _RTLENTRY  _EXPFUNC32 _dos_gettime(struct dostime_t _FAR *__timep);
  235. unsigned _RTLENTRY  _EXPFUNC32 _dos_open(const char _FAR *__pathP, unsigned __oflag,
  236.                                          int _FAR *__fd);
  237. unsigned _RTLENTRY  _EXPFUNC32 _dos_setdate(struct dosdate_t _FAR *__datep);
  238. void     _RTLENTRY  _EXPFUNC32 _dos_setdrive(unsigned __drive, unsigned _FAR *__ndrives);
  239. unsigned _RTLENTRY  _EXPFUNC32 _dos_setfileattr(const char _FAR *__filename,
  240.                                                 unsigned _FAR __attrib);
  241. unsigned _RTLENTRY  _EXPFUNC32 _dos_setftime(int __fd, unsigned __date, unsigned __time);
  242. unsigned _RTLENTRY  _EXPFUNC32 _dos_settime(struct dostime_t _FAR *__timep);
  243. void     _RTLENTRY  _EXPFUNC   disable(void);
  244. long     _RTLENTRY  _EXPFUNC   dostounix(struct date _FAR *__d, struct time _FAR *__t);
  245. void     _RTLENTRY  _EXPFUNC   enable(void);
  246. void     _RTLENTRYF _EXPFUNC32 getdate(struct date _FAR *__datep);
  247. void     _RTLENTRY  _EXPFUNC32 getdfree(unsigned char __drive,
  248.                                         struct dfree _FAR *__dtable);
  249. int      _RTLENTRY  _EXPFUNC32 _getdrive(void);
  250. void     _RTLENTRYF _EXPFUNC32 gettime(struct time _FAR *__timep);
  251. void     _RTLENTRY  _EXPFUNC32 setdate(struct date _FAR *__datep);
  252. void     _RTLENTRY  _EXPFUNC32 settime( struct time _FAR *__timep);
  253. void     _RTLENTRY  _EXPFUNC   unixtodos(long __time, struct date _FAR *__d,
  254.                                          struct time _FAR *__t);
  255. int      _RTLENTRYF _EXPFUNC32 unlink(const char _FAR *__path);
  256.  
  257.  
  258. unsigned _RTLENTRY  _EXPFUNC   _dos_read(int __fd, void *__buf, unsigned __len,
  259.                                          unsigned *__nread);
  260. unsigned _RTLENTRY  _EXPFUNC   _dos_write(int __fd, const void *__buf, unsigned __len,
  261.                                           unsigned *__nread );
  262.  
  263. #define _disable()      __emit__((unsigned char)(0xfa)) /* MSC name */
  264. #define disable()       __emit__((unsigned char)(0xfa)) /* MSC name */
  265. #define _enable()       __emit__((unsigned char)(0xfb)) /* MSC name */
  266. #define enable()        __emit__((unsigned char)(0xfb)) /* MSC name */
  267. #define geninterrupt(i) __int__(i)      /* Interrupt instruction */
  268.  
  269. /* Variables */
  270. #if defined(_RTLDLL)
  271.     extern int           _RTLENTRY __dll_argc;
  272.     extern char **       _RTLENTRY __dll_argv;
  273.     #define _argc __dll_argc
  274.     #define _argv __dll_argv
  275. #else
  276.     extern int           _RTLENTRY _EXPDATA _argc;
  277.     extern char **       _RTLENTRY _EXPDATA _argv;
  278. #endif
  279.  
  280. extern int const     _RTLENTRY _EXPDATA _8087;
  281. extern char **       _RTLENTRY _EXPDATA _environ;
  282.  
  283. extern unsigned char _RTLENTRY _EXPDATA _osmajor;
  284. extern unsigned char _RTLENTRY _EXPDATA _osminor;
  285. extern unsigned      _RTLENTRY _EXPDATA _osversion;
  286. extern unsigned      _RTLENTRY _EXPDATA _version;
  287.  
  288. void _RTLENTRY _EXPFUNC _sleep(unsigned __seconds);
  289. void _RTLENTRY _EXPFUNC sleep(unsigned __seconds);
  290.  
  291. #ifdef __MFC_COMPAT__
  292. #define _getdiskfree _dos_getdiskfree
  293. #define _diskfree_t diskfree_t
  294. #else
  295. #pragma obsolete _dos_getdiskfree
  296. #endif
  297.  
  298. #if !defined(RC_INVOKED)
  299. #pragma obsolete _dos_close
  300. #pragma obsolete _dos_creat
  301. #pragma obsolete _dos_creatnew
  302. #pragma obsolete _dos_findfirst
  303. #pragma obsolete _dos_findnext
  304. #pragma obsolete _dos_getdate
  305. #pragma obsolete _dos_getdrive
  306. #pragma obsolete _dos_getfileattr
  307. #pragma obsolete _dos_getftime
  308. #pragma obsolete _dos_gettime
  309. #pragma obsolete _dos_open
  310. #pragma obsolete _dos_read
  311. #pragma obsolete _dos_setdate
  312. #pragma obsolete _dos_setdrive
  313. #pragma obsolete _dos_setfileattr
  314. #pragma obsolete _dos_setftime
  315. #pragma obsolete _dos_settime
  316. #pragma obsolete _dos_write
  317. #pragma obsolete sleep
  318. #endif
  319.  
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323.  
  324.  
  325. #if !defined(RC_INVOKED)
  326.  
  327. /* restore default packing */
  328. #pragma pack(pop)
  329.  
  330. #if defined(__STDC__)
  331. #pragma warn .nak
  332. #endif
  333.  
  334. #endif  /* !RC_INVOKED */
  335.  
  336. #ifdef __cplusplus
  337. } // std
  338. #endif /* __cplusplus */
  339.  
  340. #endif  /* __DOS_H */
  341.  
  342. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__DOS_H_USING_LIST)
  343. #define __DOS_H_USING_LIST
  344.  
  345.     using std::dfree;
  346.     using std::diskfree_t;
  347.     using std::time;
  348.     using std::dostime_t;
  349.     using std::date;
  350.     using std::dosdate_t;
  351.     using std::ffblk;
  352.     using std::_wffblk;
  353.     using std::find_t;
  354.     using std::_dos_close;
  355.     using std::_dos_creat;
  356.     using std::_dos_creatnew;
  357.     using std::_dos_findfirst;
  358.     using std::_dos_findnext;
  359.     using std::_dos_getdate;
  360.     using std::_dos_getdiskfree;
  361.     using std::_dos_getdrive;
  362.     using std::_dos_getfileattr;
  363.     using std::_dos_getftime;
  364.     using std::_dos_gettime;
  365.     using std::_dos_open;
  366.     using std::_dos_setdate;
  367.     using std::_dos_setdrive;
  368.     using std::_dos_setfileattr;
  369.     using std::_dos_setftime;
  370.     using std::_dos_settime;
  371.     using std::disable;
  372.     using std::dostounix;
  373.     using std::enable;
  374.     using std::getdate;
  375.     using std::getdfree;
  376.     using std::_getdrive;
  377.     using std::gettime;
  378.     using std::setdate;
  379.     using std::settime;
  380.     using std::unixtodos;
  381.     using std::unlink;
  382.     using std::_dos_read;
  383.     using std::_dos_write;
  384. #if defined(_RTLDLL)
  385.     using std::__dll_argc;
  386.     using std::__dll_argv;
  387. #else
  388.     using std::_argc;
  389.     using std::_argv;
  390. #endif
  391.     using std::_8087;
  392.     using std::_environ;
  393.     using std::_osmajor;
  394.     using std::_osminor;
  395.     using std::_osversion;
  396.     using std::_version;
  397.     using std::_sleep;
  398.     using std::sleep;
  399. #endif /* __USING_CNAME__ */
  400.  
  401.